home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gsargs.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.7 KB  |  83 lines

  1. /* Copyright (C) 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gsargs.h,v 1.3 2000/09/19 19:00:25 lpd Exp $ */
  20. /* Command line argument list management */
  21.  
  22. #ifndef gsargs_INCLUDED
  23. #  define gsargs_INCLUDED
  24.  
  25. /*
  26.  * We need to handle recursion into @-files.
  27.  * The following structures keep track of the state.
  28.  * Defining a maximum argument length and a maximum nesting depth
  29.  * decreases generality, but eliminates the need for dynamic allocation.
  30.  */
  31. #define arg_str_max 2048
  32. #define arg_depth_max 10
  33. typedef struct arg_source_s {
  34.     bool is_file;
  35.     union _u {
  36.     struct _su {
  37.         char *chars;    /* original string */
  38.         gs_memory_t *memory;  /* if non-0, free chars when done with it */
  39.         const char *str;    /* string being read */
  40.     } s;
  41.     FILE *file;
  42.     } u;
  43. } arg_source;
  44. typedef struct arg_list_s {
  45.     bool expand_ats;        /* if true, expand @-files */
  46.     FILE *(*arg_fopen) (P2(const char *fname, void *fopen_data));
  47.     void *fopen_data;
  48.     const char **argp;
  49.     int argn;
  50.     int depth;            /* depth of @-files */
  51.     char cstr[arg_str_max + 1];
  52.     arg_source sources[arg_depth_max];
  53. } arg_list;
  54.  
  55. /* Initialize an arg list. */
  56. void arg_init(P5(arg_list * pal, const char **argv, int argc,
  57.           FILE * (*arg_fopen) (P2(const char *fname, void *fopen_data)),
  58.          void *fopen_data));
  59.  
  60. /*
  61.  * Push a string onto an arg list.
  62.  * This may also be used (once) to "unread" the last argument.
  63.  * If mem != 0, it is used to free the string when we are done with it.
  64.  */
  65. void arg_push_memory_string(P3(arg_list * pal, char *str, gs_memory_t * mem));
  66.  
  67. #define arg_push_string(pal, str)\
  68.   arg_push_memory_string(pal, str, (gs_memory_t *)0);
  69.  
  70. /* Clean up an arg list before exiting. */
  71. void arg_finit(P1(arg_list * pal));
  72.  
  73. /*
  74.  * Get the next arg from a list.
  75.  * Note that these are not copied to the heap.
  76.  */
  77. const char *arg_next(P1(arg_list * pal));
  78.  
  79. /* Copy an argument string to the heap. */
  80. char *arg_copy(P2(const char *str, gs_memory_t * mem));
  81.  
  82. #endif /* gsargs_INCLUDED */
  83.